package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;

import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IContactTypeDao;
import com.hy.erp.inventory.dao.interfaces.IJbpmAndOperationDao;
import com.hy.erp.inventory.pojo.JbpmAndOperation;
import com.hy.erp.inventory.pojo.interfaces.IContactType;
import com.hy.erp.inventory.pojo.interfaces.IJbpmAndOperation;
import com.hy.erp.inventory.service.interfaces.IJbpmAndOperationService;
/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-11-4；时间：下午03:42:36</li>
 * <li>类型名称：JbpmAndOperationService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@ Name ( "jbpmAndOperationService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class JbpmAndOperationService
									extends
									AbstractBusinessService < IJbpmAndOperation >
																			implements
																			IJbpmAndOperationService
{

	/**
	 * <ul>
	 * <li>开发作者：汤莉</li>
	 * <li>设计日期：2010-11-4；时间：下午03:43:03</li>
	 * <li>字段类型：long；字段名称：serialVersionUID</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 */
	private static final long	serialVersionUID	=
														4825274145205013395L ;

	public JbpmAndOperationService(){}

	@ Override
	public boolean add (
							JbpmAndOperation jbpmAndOperation )
	{
		if ( null == jbpmAndOperation)
		{
			return true ;
		}
		
		else
		{
			IJbpmAndOperationDao dao =
			                       ( IJbpmAndOperationDao ) this
			                                          .getDao ( IJbpmAndOperation.class ) ;
			IJbpmAndOperation operation=jbpmAndOperation;
			
			return dao.persist ( operation ) ;
		}
	}

	@ Override
	public String getProcessInstanceById (
											String operationId )
	{
		String processId=null;
		if(operationId==null)
		{
			return null ;
		}
		else
		{
			IJbpmAndOperationDao dao =
                ( IJbpmAndOperationDao ) this
                                   .getDao ( IJbpmAndOperation.class ) ;
			String hql="select j form JbpmAndOperation j where j.operationId='"+operationId+"'";
			List < IJbpmAndOperation > list=dao.find ( hql );
			for(IJbpmAndOperation operation:list)
			{
				JbpmAndOperation operation2=( JbpmAndOperation ) operation;
				processId= operation2.getProcessInstanceId ( );
			}
			return processId;
		}
		
	}

}
